<?php

/**
 * Gestionnaire de l'application maitre
 *
 * @category   McCube
 * @package    Bundle
 * @author     Leiha Sellier <leiha.sellier@gmail.com>
 * @license    http://creativecommons.org/licenses/by/3.0/  CC BY 3.0
 * @link       http://code.google.com/p/mechanics-cubes/
 */
class McCube_Bundle_Application extends McCube_Bundle{

    public static $environment = null;

    // --------------------------------------------------

    public $config    = array();
    public $router    = array();
    public $route     = array();
    public $database  = null;
    public $session   = null;

    /** */
    public function __construct($rootPath, $environment){
        parent::__construct('application', $rootPath, $this);
        $this->config = $this->getConfig('default', true);

        self::$environment = $environment;

        $this->_initNotifier();
        $this->_initDatabase();
        $this->_initTemplateEngine();
    }

    /** */
    protected function _initNotifier(){
        McCube_Notifier::init($this->config['notifier']);
    }


    /** */
    protected function _initDatabase(){
        if(isset($this->config['database']))
            $this->database = McCube_Db::getInstanceOf($this->config['database']);
    }

    /** */
    protected function _initTemplateEngine(){
        if(isset($this->config['template'])){
            McCube_Template::init($this->config['template']);
        }
    }
}